<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<sec:authorize access="hasAnyRole('ROLE_ADD_USR','ROLE_EDIT_USR','ROLE_DELETE_USR')">
<!-- Bread crumb is created dynamically -->
<!-- row -->
<div class="row">
	
	
</div>
<!-- end row -->

<!-- widget grid -->
<section id="widget-grid" class="">

<!-- NEW COL START -->
		<article class="col-sm-12 col-md-12 col-lg-6">

			<!-- Widget ID (each widget will need unique ID)-->
			<div class="jarviswidget" id="wid-id-1" data-widget-colorbutton="false" data-widget-editbutton="false" data-widget-custombutton="false">

				<header>
					<span class="widget-icon"> <i class="fa fa-edit"></i> </span>
					<h2>Permisos Usuario  </h2>

				</header>

				<!-- widget div-->
				<div>

					<!-- widget edit box -->
					<div class="jarviswidget-editbox">
						<!-- This area used as dropdown edit box -->

					</div>
					<!-- end widget edit box -->

					<!-- widget content -->
					<div class="widget-body no-padding">

						<c:set scope="page" var="count" value="0" />
						<form:form cssClass="smart-form" modelAttribute="usuarioView" method="post">
							<header>
								Usuario: ${usuarioView.nombre}
							</header>
	
								<c:forEach var="entry" items="${usuarioPermisos}" varStatus="mapLoop">
									<fieldset>
										<label class="label"> ${entry.key} </label>
										<c:forEach var="row" items="${entry.value}" varStatus="loop">
											<div class="row">
												<div class="col col-4">
													<label class="checkbox">
														 <input type="checkbox" name="permisos[${count}].selected" <c:if test="${row.selected}">checked="checked"</c:if> />
														<i></i>${row.nombrePermiso}
													</label>
												</div>
											</div>
											<input type="hidden" name="permisos[${count}].permisoId" value="${row.permisoId}">
										    <input type="hidden" name="permisos[${count}].nombrePermiso" value="${row.nombrePermiso}">
											<c:set var="count" value="${count + 1}" scope="page"/>
										</c:forEach>									
									</fieldset>
								</c:forEach>
								
								<footer>
									<button type="submit" class="btn btn-primary">
										Editar
									</button>
									<button type="button" class="btn btn-default" onclick="window.history.back();">
										Regresar
									</button>
								</footer>
								<form:hidden path="userId"/>
								<form:hidden path="username"/>
								<form:hidden path="nombre"/>
								<form:hidden path="activo"/>
							</form:form>			
					</div>
							
				</div>
							
			</div>
							
		</article>		
	
</section>


<!-- end widget grid -->

<script type="text/javascript">
	
	/* DO NOT REMOVE : GLOBAL FUNCTIONS!
	 *
	 * pageSetUp(); WILL CALL THE FOLLOWING FUNCTIONS
	 *
	 * // activate tooltips
	 * $("[rel=tooltip]").tooltip();
	 *
	 * // activate popovers
	 * $("[rel=popover]").popover();
	 *
	 * // activate popovers with hover states
	 * $("[rel=popover-hover]").popover({ trigger: "hover" });
	 *
	 * // activate inline charts
	 * runAllCharts();
	 *
	 * // setup widgets
	 * setup_widgets_desktop();
	 *
	 * // run form elements
	 * runAllForms();
	 *
	 ********************************
	 *
	 * pageSetUp() is needed whenever you load a page.
	 * It initializes and checks for all basic elements of the page
	 * and makes rendering easier.
	 *
	 */

	pageSetUp();
	
	/*
	 * ALL PAGE RELATED SCRIPTS CAN GO BELOW HERE
	 * eg alert("my home function");
	 * 
	 * var pagefunction = function() {
	 *   ...
	 * }
	 * loadScript("js/plugin/_PLUGIN_NAME_.js", pagefunction)
	 * 
	 * TO LOAD A SCRIPT:
	 * var pagefunction = function (){ 
	 *  loadScript(".../plugin.js", run_after_loaded);	
	 * }
	 * 
	 * OR you can load chain scripts by doing
	 * 
	 * loadScript(".../plugin.js", function(){
	 * 	 loadScript("../plugin.js", function(){
	 * 	   ...
	 *   })
	 * });
	 */
	
	// pagefunction
	
	var pagefunction = function() {
		// clears the variable if left blank
	};
	
	// end pagefunction
	
	// run pagefunction
	pagefunction();
	
</script>

</sec:authorize>